package com.metaera.app.data.model;

import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
 * Author: LJD
 * Date: 2019/11/13
 * Desc: 列表基础模型
 */
public class BasicListResponse<T> extends BasicResponse<BasicListResponse.PageDataEntity<T>> {

    public BasicListResponse() {
    }


    public BasicListResponse(PageDataEntity<T> data) {
        super(data);
    }

    public BasicListResponse(PageDataEntity<T> data, int code, String msg) {
        super(data, code, msg);
    }

    public static class PageDataEntity<T> {

        @SerializedName("list")
        private List<T> items;

        @SerializedName("pageNum")
        private int page;

        private int total;

        @SerializedName("pageSize")
        private int page_size;

        public PageDataEntity() {
        }

        public PageDataEntity(List<T> items, int page) {
            this.items = items;
            this.page = page;
        }

        public boolean hasMore() {
            return (page * page_size) < total;
        }

        public List<T> getList() {
            return items;
        }

        public List<T> getItems() {
            return items;
        }

        public void setItems(List<T> items) {
            this.items = items;
        }

        public int getPage() {
            return page;
        }

        public void setPage(int page) {
            this.page = page;
        }

        public int getTotal() {
            return total;
        }

        public void setTotal(int total) {
            this.total = total;
        }

        public int getPage_size() {
            return page_size;
        }

        public void setPage_size(int page_size) {
            this.page_size = page_size;
        }
    }

}
